Current File : //usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_sendmsg.cpython-312.pyc
�

Ϫ�f(���dZddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
mZmZm
Z
m	Z	ddlmZ	ddl	mZmZdZdd	lmZdd
lmZddlmZmZddlmZdd
lmZddlm Z ddl!m"Z"ddl#m$Z$e"jJ�r	ddl	m&Z&dZ'ndZ'	ddl(m)Z)m*Z*m+Z+m,Z,dZ-dZ.Gd�d�Z/d�Z0Gd�de1�Z2Gd�de�Z3d�Z4ee-e.�Gd�de$��Z5ee-e.�Gd�d e$��Z6y#e$rdZY��wxYw#e$rdZ-dZ.Y�mwxYw)!z&
Tests for L{twisted.python.sendmsg}.
�N)�close�pathsep�pipe�read)�AF_INET�AF_INET6�
SOL_SOCKET�error�socket)�pack)�AF_UNIX�
socketpairFT)�skipIf)�reactor)�Deferred�inlineCallbacks)�ProcessDone)�ProcessProtocol)�FilePath)�platform)�TestCase)�MSG_DONTWAIT)�
SCM_RIGHTS�getSocketFamily�recvmsg�sendmsg�z!Platform doesn't support sendmsg.c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�	_FDHolderzP
    A wrapper around a FD that will remember if it has been closed or not.
    c��||_y�N��_fd)�self�fds  �B/usr/lib/python3/dist-packages/twisted/python/test/test_sendmsg.py�__init__z_FDHolder.__init__:s	�����c��|jS)z/
        Return the fileno of this FD.
        r"�r$s r&�filenoz_FDHolder.fileno=s
���x�x�r(c�V�|jrt|j�d|_yy)zH
        Close the FD. If it's already been closed, do nothing.
        N)r#rr*s r&rz_FDHolder.closeCs"���8�8��$�(�(�O��D�H�r(c��|jr9tjd|j�d�t�|j	�yy)z>
        If C{self._fd} is unclosed, raise a warning.
        zFD z was not closed!N)r#�warnings�warn�ResourceWarningrr*s r&�__del__z_FDHolder.__del__Ks5���8�8��M�M�C����z�)9�:�O�L��J�J�L�r(c��|Sr!�r*s r&�	__enter__z_FDHolder.__enter__Ss���r(c�$�|j�yr!)r)r$�exc_type�	exc_value�	tracebacks    r&�__exit__z_FDHolder.__exit__Vs���
�
�r(N)
�__name__�
__module__�__qualname__�__doc__r'r+rr1r4r9r3r(r&rr5s%��������r(rc�H�t�\}}t|�t|�fS)zI
    Create a pipe, and return the two FDs wrapped in L{_FDHolders}.
    )rr)�r�ws  r&�	_makePiperAZs"���6�D�A�q��a�L�)�A�,�'�'r(c��eZdZdZdefd�Zy)�ExitedWithStderrz,
    A process exited with some stderr.
    �returnc�h�djdgt|j�z�}t|�S)zY
        Dump the errors in a pretty way in the event of a subprocess traceback.
        �
r()�join�list�args�repr�r$�results  r&�__str__zExitedWithStderr.__str__gs+�����S�E�D����O�3�4���F�|�r(N)r:r;r<r=�strrMr3r(r&rCrCbs�����r(rCc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�StartStopProcessProtocola�
    An L{IProcessProtocol} with a Deferred for events where the subprocess
    starts and stops.

    @ivar started: A L{Deferred} which fires with this protocol's
        L{IProcessTransport} provider when it is connected to one.

    @ivar stopped: A L{Deferred} which fires with the process output or a
        failure if the process produces output on standard error.

    @ivar output: A C{str} used to accumulate standard output.

    @ivar errors: A C{str} used to accumulate standard error.
    c�\�t�|_t�|_d|_d|_y)Nr()r�started�stopped�output�errorsr*s r&r'z!StartStopProcessProtocol.__init__s"���z����z��������r(c�N�|jj|j�yr!)rR�callback�	transportr*s r&�connectionMadez'StartStopProcessProtocol.connectionMade�s�������d�n�n�-r(c�.�|xj|z
c_yr!)rT�r$�datas  r&�outReceivedz$StartStopProcessProtocol.outReceived�������t��r(c�.�|xj|z
c_yr!)rUr[s  r&�errReceivedz$StartStopProcessProtocol.errReceived�r^r(c���|jt�r&|jj|j�y|jjt
|j|j��yr!)�checkrrSrWrT�errbackrCrU)r$�reasons  r&�processEndedz%StartStopProcessProtocol.processEnded�sF���<�<��$��L�L�!�!�$�+�+�.��L�L� � �!1�$�+�+�t�{�{�!K�Lr(N)	r:r;r<r=r'rYr]r`rer3r(r&rPrPos!��
��.���Mr(rPc���ttj�j�j}ttj�}ttjtj��j�j|d<t�}tj|||tt�j|dz�j�jdg|ddd|d���|S)z�
    Start a script that is a peer of this test as a subprocess.

    @param script: the module name of the script in this directory (no
        package prefix, no '.py')
    @type script: C{str}

    @rtype: L{StartStopProcessProtocol}
    �
PYTHONPATHz.pys17r@r?)r���)�env�childFDs)r�sys�
executable�
asTextMode�path�dict�os�environrrGrPr�spawnProcess�__file__�sibling)�script�outputFD�pyExerk�sspps     r&�_spawnr{�s���
�S�^�^�$�/�/�1�6�6�E�
�r�z�z�
�C� ����c�h�h�!7�8�C�C�E�J�J�C���#�%�D�����
���X��&�&�v��~�6�A�A�C�H�H��	
�

��S�S�h�7�
��Kr(c�h�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
eed	�d
��Z
ed��Zy)
�SendmsgTestszB
    Tests for the Python2/3 compatible L{sendmsg} interface.
    c�<�tt�\|_|_y)z0
        Create a pair of UNIX sockets.
        N)rr
�inputrTr*s r&�setUpzSendmsgTests.setUp�s��#-�W�"5���
�D�Kr(c�l�|jj�|jj�y)z4
        Close the sockets opened by setUp.
        N)rrrTr*s r&�tearDownzSendmsgTests.tearDown�s$��	
�
�
���������r(c���|jj�|jtt|jd�}|j|jdtj�y)z�
        If the underlying C{sendmsg} call fails, L{send1msg} raises
        L{socket.error} with its errno set to the underlying errno value.
        �hello, worldrN�	rr�assertRaisesr
r�assertEqualrI�errno�EBADF�r$�excs  r&�test_syscallErrorzSendmsgTests.test_syscallError�sJ��
	
�
�
��������w��
�
�O�L��������!��e�k�k�2r(c���|jj�|jtt|jddgd�}|j|jdtj�y)z�
        The behavior when the underlying C{sendmsg} call fails is the same
        whether L{sendmsg} is passed ancillary data or not.
        r�)rrs0123rNr�r�s  r&�#test_syscallErrorWithControlMessagez0SendmsgTests.test_syscallErrorWithControlMessage�sV��
	
�
�
��������7�D�J�J��/�9J�A�
��	
������!��e�k�k�2r(c�8�d}|jt|�t|j|��t	|j
�}|j|jd�|j|jd�|j|jg�y)zI
        L{recvmsg} will retrieve a message sent via L{sendmsg}.
        �
hello, world!rN)	r��lenrrrrTr\�flags�	ancillary)r$�messagerLs   r&�test_roundtripzSendmsgTests.test_roundtrip�su��#������W��w�t�z�z�7�'C�D�����%��������&6�7�������q�)�����)�)�2�.r(c�*�ddzdz}|jjd�t|j|�}|j|t	|�k�t|jt	|��}|jt	|d�|�y)zS
        L{sendmsg} returns the number of bytes which it was able to send.
        �xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx��FrN)r�setblockingr�
assertTruer�rrTr�)r$r��sent�receiveds    r&�test_shortsendzSendmsgTests.test_shortsend�sy����$�r�)���
�
���u�%��t�z�z�7�+��
	
����s�7�|�+�,��4�;�;��G��5������X�a�[�)�4�0r(c��t|jdgd�t|j�}|j	|dgdf�y)z�
        L{sendmsg} treats an empty ancillary data list the same way it treats
        receiving no argument for the ancillary parameter at all.
        r�rN)rrrrTr�rKs  r&�test_roundtripEmptyAncillaryz)SendmsgTests.test_roundtripEmptyAncillary�s=��
	��
�
�,�b�!�4�����%������"2�B��!:�;r(z7MSG_DONTWAIT is only known to work as intended on Linuxc��td�D]}	t|jdt���!|jd�y#t$r8}|j|jdtj�Yd}~yd}~wwxYw)z�
        The C{flags} argument to L{sendmsg} is passed on to the underlying
        C{sendmsg} call, to affect it in whatever way is defined by those
        flags.
        i r�)r�rNzHFailed to fill up the send buffer, or maybe send1msg blocked for a while)
�rangerrr�OSErrorr�rIr��EAGAIN�fail)r$�i�es   r&�
test_flagszSendmsgTests.test_flags�sp���x��
	�A�
���
�
�K�|�D�
	�
�I�I�8�
��	�
�� � ������E�L�L�9���
�s�A�	B�	-A<�<Bc#�^K�td|jj��}|j��t	�\}}|j|j�|j|j�|5t|jdtttd|j��fg�ddd�|j��|jt|j�d�d�|jt|j�d�d�y#1swY�lxYw�w)z�
        Calling L{sendmsg} with SOL_SOCKET, SCM_RIGHTS, and a platform-endian
        packed file descriptor number should send that file descriptor to a
        different process, where it can be retrieved by using L{recv1msg}.
        �pullpipesblonkr�Nr�sTest fixture data: blonk.
r()r{rTr+rRrA�
addCleanuprrrr	rrrSr�r)r$rz�pipeOut�pipeIns    r&�test_sendSubProcessFDz"SendmsgTests.test_sendSubProcessFDs������j�$�+�+�"4�"4�"6�7���l�l��#�+��������
�
�&�������%�
�	���
�
���j�$�s�F�M�M�O�*D�E�F�
�	��l�l������g�n�n�.��5�7U�V�����g�n�n�.��5�s�;�	�	�s�A8D-�:<D!�6A+D-�!D*�&D-N)r:r;r<r=r�r�r�r�r�r�r�r�dontWaitSkipr�rr�r3r(r&r}r}�s[���6��3�	3�
/�
1�<��L�S�T��U��*�<��<r(r}c�@�eZdZdZd�Zd�Zd�Zeed�d��Z	y)�GetSocketFamilyTestsz'
    Tests for L{getSocketFamily}.
    c�R�t|�}|j|j�|S)z�
        Create a new socket using the given address family and return that
        socket's file descriptor.  The socket will automatically be closed when
        the test is torn down.
        )rr�r)r$�
addressFamily�ss   r&�_socketzGetSocketFamilyTests._socket3s#��
�=�!�������� ��r(c�h�|jtt|jt���y)z�
        When passed the file descriptor of a socket created with the C{AF_INET}
        address family, L{getSocketFamily} returns C{AF_INET}.
        N)r�rrr�r*s r&�	test_inetzGetSocketFamilyTests.test_inet=s"��
	
����/�$�,�,�w�2G�"H�Ir(c�h�|jtt|jt���y)z�
        When passed the file descriptor of a socket created with the
        C{AF_INET6} address family, L{getSocketFamily} returns C{AF_INET6}.
        N)r�rrr�r*s r&�
test_inet6zGetSocketFamilyTests.test_inet6Ds"��
	
����?�4�<�<��3I�#J�Kr(z)Platform does not support AF_UNIX socketsc�h�|jtt|jt���y)z�
        When passed the file descriptor of a socket created with the C{AF_UNIX}
        address family, L{getSocketFamily} returns C{AF_UNIX}.
        N)r�r
rr�r*s r&�	test_unixzGetSocketFamilyTests.test_unixKs"��	
����/�$�,�,�w�2G�"H�Ir(N)
r:r;r<r=r�r�r�r�nonUNIXSkipr�r3r(r&r�r�-s7����J�L��K�D�E�J�F�Jr(r�)7r=r�rrrmr.rrrrrrrr	r
�structrr
rr��ImportError�unittestr�twisted.internetr�twisted.internet.deferrr�twisted.internet.errorr�twisted.internet.protocolr�twisted.python.filepathr�twisted.python.runtimer�twisted.trial.unittestr�isLinuxrr��twisted.python.sendmsgrrrr�doImportSkip�importSkipReasonrrA�	ExceptionrCrPr{r}r�r3r(r&�<module>r�s2���
�	�
��)�)�?�?���*��K��$�<�.�5�,�+�+��8����#��L��L��T�T�
�L���"�"�J(�
�y�
�#M��#M�L�8��&�'�x<�8�x<�(�x<�v��&�'�#J�8�#J�(�#J��y���K���6�;��L�:��;�s#�C2�
C?�2C<�;C<�?	D�
D
Page Not Found
Parece que el enlace que apuntaba aquí no sirve. ¿Quieres probar con una búsqueda?
¡Hola!